package com.aisile.controller;

import com.aisile.admin.AdChannelApi;
import com.aisile.model.admin.dtos.ChannelDto;
import com.aisile.model.admin.pojos.AdChannel;
import com.aisile.model.common.dtos.ResponseResult;
import com.aisile.service.AdChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/api/admin/ad_channel")
public class AdChannelController implements AdChannelApi {
    @Autowired
    private AdChannelService adChannelService;
    //查看频道
    @PostMapping("/list")
    @Override
    public ResponseResult findAll(@RequestBody ChannelDto channelDto) {
        return adChannelService.findAll(channelDto);
    }
    @PostMapping("/save")
//   添加频道
    @Override
    public ResponseResult saveAdChennal(@RequestBody AdChannel adChannel) {
        return adChannelService.saveAdChennal(adChannel);
    }
    @PutMapping("/update")
//   修改频道
    @Override
    public ResponseResult updateAdCennal(@RequestBody AdChannel adChannel) {
        return adChannelService.updateAdCennal(adChannel);
    }
@DeleteMapping("/delete/{id}")
    @Override
    public ResponseResult deleteAdCennal(@PathVariable int id) {
        return adChannelService.deleteAdCennal(id);
    }
   @PostMapping("/delMany")
    @Override
    public ResponseResult delManyAdCennal(@RequestBody List<Integer> list) {
        return adChannelService.delManyAdCennal(list);
    }
     @GetMapping("/getbyId/{id}")
    @Override
    public ResponseResult getbyId(@PathVariable int id) {
        return adChannelService.getbyId(id);
    }
}
